package com.okaixz.client.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.okaixz.client.mapper.KbAssistantMapper;
import com.okaixz.client.model.domain.KbAssistant;
import com.okaixz.client.service.IKbAssistantService;
import com.okaixz.common.constant.CommonConstants;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * ai应用信息表 服务实现类
 * </p>
 *
 * @author cdz
 * @since 2025-05-15
 */
@Service
public class KbAssistantServiceImplClient extends ServiceImpl<KbAssistantMapper, KbAssistant> implements IKbAssistantService {

    @Override
    public List<KbAssistant> selectKbAssistantList(String tabId, Integer sex) {
        List<KbAssistant> list = lambdaQuery()
                .eq(KbAssistant::getTabId, tabId)
                .in(KbAssistant::getSex, sex, 0)
                .list();
        return list;
    }

    @Override
    public List<KbAssistant> defaultlist(Integer sex) {
        List<KbAssistant> list = lambdaQuery()
                .eq(KbAssistant::getIsDefault, 1)
                .in(KbAssistant::getSex, sex, 0)
                .orderByDesc(KbAssistant::getOrderNum)
                .list();
        return list;
    }

    @Override
    public List<KbAssistant> baselist(Integer sex) {
        List<KbAssistant> list = lambdaQuery()
                .eq(KbAssistant::getTabId, CommonConstants.KB_BASE_TABID)
                .list();
        return list;
    }

    @Override
    public List<KbAssistant> getHotList(Integer sex) {
        List<KbAssistant> list = lambdaQuery()
                .eq(KbAssistant::getSex, sex)
                .orderByDesc(KbAssistant::getUseCount)
                .last("LIMIT 20")
                .list();
        return list;
    }
}
